
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

<title>手机号绑定</title>
<link rel="stylesheet" href="__TMPL__/public/user/css/phone.css">
<link rel="stylesheet" type="text/css" href="__TMPL__/public/user/css/weui.min.css">
<link rel="stylesheet" type="text/css" href="__TMPL__/public/user/css/jquery-weui.css">
<link rel="stylesheet" type="text/css" href="__TMPL__/public/user/css/demos.css">

</head>

<body>
<div class="header"  style="border-bottom: 1px solid #d7d7d75e;">
    <h1>手机号绑定</h1>
    <a href="javascript:history.back(-1);" class="back"><span></span></a>
    <a href="javascript:;" class=""></a>
</div>
<form style="margin:8px" action="#" method="post" >


  <div class="weui_cell">
    <div class="weui_cell_hd">
      <lab el class="weui_label">手机号：</label>
    </div>
    <div class="weui_cell_bd weui_cell_primary">
      <input class="weui_input" type="tel" id="mobile" name="tell" placeholder="请输入手机号">
    </div>
  </div>
  <div class="weui_cell">
    <div class="weui_cell_hd">
      <label class="weui_label">验证码：</label>
    </div>
    <div class="weui_cell_bd weui_cell_primary">
      <input class="weui_input" type="tel" id="certifycode" name="certifycode" placeholder="请输入验证码">
    </div>
    <div class="weui_cell_ft"> 
    
    <input style="width: 110px;background: #23262F;" type="button" class="weui_btn weui_btn weui_btn_mini weui_btn_primary" value="获取验证码"  id="sendOutCode"  />  </div>
  </div>
   <div class="weui_cell"></div>
  <div class="weui_btn_area" style="margin-top:20px;"> <a class="weui_btn weui_btn_primary" type="button" style="background-color: #23262f;color: #d9b97c;border: #000000 1px solid!important;box-shadow: 0 0 8px #000000;" id="sendbtn" >提交</a> </div>
</form>
<script src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/layer/layer.js"></script>
<script type="text/javascript">
$(function(){
    var wait=120;
    $('#sendOutCode').click(function(){
      var mobile = $("#mobile").val();
              //验证手机号格式是否正确
              if(mobile.search(/^1(3|4|5|7|8)\d{9}$/) == -1){
                  $("#mobile").trigger("focus");
                  layer.msg("请输入正确的手机格式");
                  return false;
              }
              $.ajax({
                  type: "POST",
                  url: "/user/verification_code/send2.html",
                  data: {"username":mobile},
                  success: function(data){
                      layer.msg(data.msg);
                      if(data['code']==1){
                          time();
                      }
                  }
              });
    })
    $('#sendbtn').click(function(){
      var mobile = $("#mobile").val();
      var certifycode = $("#certifycode").val();
              //验证手机号格式是否正确
              if(mobile.search(/^1(3|4|5|7|8)\d{9}$/) == -1){
                  $("#mobile").trigger("focus");
                  layer.msg("请输入正确的手机格式");
                  return false;
              }
              if(certifycode==''){
                $("#certifycode").trigger("focus");
                  layer.msg("请输入手机验证码");
                  return false;
              }
              $.ajax({
                  type: "POST",
                  url: "/user/index/b_phone.html",
                  data: {"username":mobile,"certifycode":certifycode},
                  success: function(data){
                      layer.msg(data.msg);
                     if(data["code"]==1 ){
                        var usercenter="/user/profile/center.html";
                        setTimeout(function(){location.href =usercenter },1000);
                    }
                }
               
              });
    })
   function time() {
            if (wait == 0) {
                $("#sendOutCode").removeAttr("disabled");               
                $("#sendOutCode").css("background-color", "#23262f");
                $("#sendOutCode").css("color", "#ffffff");
                $("#sendOutCode").val("获取验证码");
                wait = 120;
            } else {
                $("#sendOutCode").attr("disabled", 'disabled');
                $("#sendOutCode").css("background-color", "#949494");
                $("#sendOutCode").css("color", "#ccc");
                $("#sendOutCode").val(wait+"s");
                wait--;
                setTimeout(function() {
                        time()
                    },
                    1000)
            }
     }

})
</script>
</body>
</html>
